package com.tencent.wxcloudrun.common.config;

import com.tencent.wxcloudrun.common.CheckParamsInterceptor;
import com.tencent.wxcloudrun.common.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    CheckParamsInterceptor checkSourceInterceptor = new CheckParamsInterceptor();
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkSourceInterceptor).addPathPatterns("/**");
        registry.addInterceptor(jwtInterceptor_t())
                .addPathPatterns("/**").excludePathPatterns(
                 "/user/login",
                "/user/register",
                "/common/**",
                "/user/upload",
                "/unit/getTable",
                "/variety/list",
                "/variety/addOrderVariety",
                "/order/add",
                "/order/menuList",
                "/order/select",
                "/order/pageList",
                "/unit/getNormsWeApp",
                "/unit/test",
                "/unit/addNewOrder",
                "/unit/getOpenId"
                );
    }
    @Bean
    public JwtInterceptor jwtInterceptor_t(){
        return new JwtInterceptor();
    }
}
